<?php

if(!defined('_HTML_NAVIGATION_')) {
define('_HTML_NAVIGATION_', 1);

function itstock_html_navigation(&$data) {
  if(itstock_search_count($data)){
    $total = $data['total'][0]['total'];
    $start =  $data['offset'] + 1;
    $end = $total;
    $url_get = $_GET;
    if(isset($url_get['idx'])) unset($url_get['idx']);
    $url_search = http_build_query($url_get);
    $search_arrows = '';

    if(isset($data['ajax_nav'])) {
      $arrow_sintax = '&nbsp;<label onclick="'.$data['ajax_nav'].';" title="%s" ><img style="vertical-align: text-bottom;" src="img/arrow-%s.png"></label>';
    } else {
      $arrow_sintax = '&nbsp;<a href="?%s&idx=%s" title="%s"><img style="vertical-align: text-bottom;" src="img/arrow-%s.png"></a>';
    }
    if($data['offset'] > 0) {
      if(isset($data['ajax_nav'])) {
        $search_arrows .= sprintf($arrow_sintax, $data['page_idx'] - 1, 'Go Back', 'left');
      } else {
        $search_arrows .= sprintf($arrow_sintax, $url_search, $data['page_idx'] - 1, 'Go Back', 'left');
      }
    }
    if(($data['offset'] + _ITSTOCK_MAX_ROWS_) < $total) {
      if(isset($data['ajax_nav'])) {
        $search_arrows .= sprintf($arrow_sintax, $data['page_idx'] + 1, 'Go Next', 'right');
      } else {
        $search_arrows .= sprintf($arrow_sintax, $url_search, $data['page_idx'] + 1, 'Go Next', 'right');
      }
      $end = $data['offset'] + _ITSTOCK_MAX_ROWS_;
    }
    printf("%s-%s de %s %s",$start, $end, $total, $search_arrows);
  }
}

}
?>
